/**
 * Copyright &copy; 2012-2016 <a href="https://github.com/thinkgem/jeesite">JeeSite</a> All rights reserved.
 */
package com.thinkgem.jeesite.modules.hk.sys.web.currency;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.thinkgem.jeesite.common.config.Global;
import com.thinkgem.jeesite.common.persistence.Page;
import com.thinkgem.jeesite.common.web.BaseController;
import com.thinkgem.jeesite.common.utils.StringUtils;
import com.thinkgem.jeesite.modules.hk.sys.entity.currency.HkUserFeedback;
import com.thinkgem.jeesite.modules.hk.sys.service.currency.HkUserFeedbackService;

/**
 * 系统反馈Controller
 * @author 李欣荣
 * @version 2018-09-30
 */
@Controller
@RequestMapping(value = "${adminPath}/sys/currency/hkUserFeedback")
public class HkUserFeedbackController extends BaseController {

	@Autowired
	private HkUserFeedbackService hkUserFeedbackService;
	
	@ModelAttribute
	public HkUserFeedback get(@RequestParam(required=false) String id) {
		HkUserFeedback entity = null;
		if (StringUtils.isNotBlank(id)){
			entity = hkUserFeedbackService.get(id);
		}
		if (entity == null){
			entity = new HkUserFeedback();
		}
		return entity;
	}
	
	@RequiresPermissions("sys:currency:hkUserFeedback:view")
	@RequestMapping(value = {"list", ""})
	public String list(HkUserFeedback hkUserFeedback, HttpServletRequest request, HttpServletResponse response, Model model) {
		Page<HkUserFeedback> page = hkUserFeedbackService.findPage(new Page<HkUserFeedback>(request, response), hkUserFeedback); 
		model.addAttribute("page", page);
		return "hk/sys/currency/hkUserFeedbackList";
	}

	@RequiresPermissions("sys:currency:hkUserFeedback:view")
	@RequestMapping(value = "form")
	public String form(HkUserFeedback hkUserFeedback, Model model) {
		model.addAttribute("hkUserFeedback", hkUserFeedback);
		return "hk/sys/currency/hkUserFeedbackForm";
	}

	@RequiresPermissions("sys:currency:hkUserFeedback:edit")
	@RequestMapping(value = "save")
	public String save(HkUserFeedback hkUserFeedback, Model model, RedirectAttributes redirectAttributes) {
		if (!beanValidator(model, hkUserFeedback)){
			return form(hkUserFeedback, model);
		}
		hkUserFeedbackService.save(hkUserFeedback);
		addMessage(redirectAttributes, "保存系统反馈成功");
		return "redirect:"+Global.getAdminPath()+"/sys/currency/hkUserFeedback/?repage";
	}
	
	@RequiresPermissions("sys:currency:hkUserFeedback:edit")
	@RequestMapping(value = "delete")
	public String delete(HkUserFeedback hkUserFeedback, RedirectAttributes redirectAttributes) {
		hkUserFeedbackService.delete(hkUserFeedback);
		addMessage(redirectAttributes, "删除系统反馈成功");
		return "redirect:"+Global.getAdminPath()+"/sys/currency/hkUserFeedback/?repage";
	}

}